<?php


abstract class BaseExamfis extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $numhistoria;


	
	protected $ta;


	
	protected $pulso;


	
	protected $fc;


	
	protected $fresp;


	
	protected $peso;


	
	protected $talla;

	
	protected $aHistoria;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getNumhistoria()
	{

		return $this->numhistoria;
	}

	
	public function getTa()
	{

		return $this->ta;
	}

	
	public function getPulso()
	{

		return $this->pulso;
	}

	
	public function getFc()
	{

		return $this->fc;
	}

	
	public function getFresp()
	{

		return $this->fresp;
	}

	
	public function getPeso()
	{

		return $this->peso;
	}

	
	public function getTalla()
	{

		return $this->talla;
	}

	
	public function setId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = ExamfisPeer::ID;
		}

	} 
	
	public function setNumhistoria($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->numhistoria !== $v) {
			$this->numhistoria = $v;
			$this->modifiedColumns[] = ExamfisPeer::NUMHISTORIA;
		}

		if ($this->aHistoria !== null && $this->aHistoria->getNumhistoria() !== $v) {
			$this->aHistoria = null;
		}

	} 
	
	public function setTa($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->ta !== $v) {
			$this->ta = $v;
			$this->modifiedColumns[] = ExamfisPeer::TA;
		}

	} 
	
	public function setPulso($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->pulso !== $v) {
			$this->pulso = $v;
			$this->modifiedColumns[] = ExamfisPeer::PULSO;
		}

	} 
	
	public function setFc($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->fc !== $v) {
			$this->fc = $v;
			$this->modifiedColumns[] = ExamfisPeer::FC;
		}

	} 
	
	public function setFresp($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->fresp !== $v) {
			$this->fresp = $v;
			$this->modifiedColumns[] = ExamfisPeer::FRESP;
		}

	} 
	
	public function setPeso($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->peso !== $v) {
			$this->peso = $v;
			$this->modifiedColumns[] = ExamfisPeer::PESO;
		}

	} 
	
	public function setTalla($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->talla !== $v) {
			$this->talla = $v;
			$this->modifiedColumns[] = ExamfisPeer::TALLA;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->numhistoria = $rs->getInt($startcol + 1);

			$this->ta = $rs->getInt($startcol + 2);

			$this->pulso = $rs->getInt($startcol + 3);

			$this->fc = $rs->getInt($startcol + 4);

			$this->fresp = $rs->getInt($startcol + 5);

			$this->peso = $rs->getInt($startcol + 6);

			$this->talla = $rs->getInt($startcol + 7);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 8; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Examfis object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(ExamfisPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			ExamfisPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(ExamfisPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


												
			if ($this->aHistoria !== null) {
				if ($this->aHistoria->isModified()) {
					$affectedRows += $this->aHistoria->save($con);
				}
				$this->setHistoria($this->aHistoria);
			}


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = ExamfisPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += ExamfisPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


												
			if ($this->aHistoria !== null) {
				if (!$this->aHistoria->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aHistoria->getValidationFailures());
				}
			}


			if (($retval = ExamfisPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = ExamfisPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getNumhistoria();
				break;
			case 2:
				return $this->getTa();
				break;
			case 3:
				return $this->getPulso();
				break;
			case 4:
				return $this->getFc();
				break;
			case 5:
				return $this->getFresp();
				break;
			case 6:
				return $this->getPeso();
				break;
			case 7:
				return $this->getTalla();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = ExamfisPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getNumhistoria(),
			$keys[2] => $this->getTa(),
			$keys[3] => $this->getPulso(),
			$keys[4] => $this->getFc(),
			$keys[5] => $this->getFresp(),
			$keys[6] => $this->getPeso(),
			$keys[7] => $this->getTalla(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = ExamfisPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setNumhistoria($value);
				break;
			case 2:
				$this->setTa($value);
				break;
			case 3:
				$this->setPulso($value);
				break;
			case 4:
				$this->setFc($value);
				break;
			case 5:
				$this->setFresp($value);
				break;
			case 6:
				$this->setPeso($value);
				break;
			case 7:
				$this->setTalla($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = ExamfisPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setNumhistoria($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setTa($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setPulso($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setFc($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setFresp($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setPeso($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setTalla($arr[$keys[7]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(ExamfisPeer::DATABASE_NAME);

		if ($this->isColumnModified(ExamfisPeer::ID)) $criteria->add(ExamfisPeer::ID, $this->id);
		if ($this->isColumnModified(ExamfisPeer::NUMHISTORIA)) $criteria->add(ExamfisPeer::NUMHISTORIA, $this->numhistoria);
		if ($this->isColumnModified(ExamfisPeer::TA)) $criteria->add(ExamfisPeer::TA, $this->ta);
		if ($this->isColumnModified(ExamfisPeer::PULSO)) $criteria->add(ExamfisPeer::PULSO, $this->pulso);
		if ($this->isColumnModified(ExamfisPeer::FC)) $criteria->add(ExamfisPeer::FC, $this->fc);
		if ($this->isColumnModified(ExamfisPeer::FRESP)) $criteria->add(ExamfisPeer::FRESP, $this->fresp);
		if ($this->isColumnModified(ExamfisPeer::PESO)) $criteria->add(ExamfisPeer::PESO, $this->peso);
		if ($this->isColumnModified(ExamfisPeer::TALLA)) $criteria->add(ExamfisPeer::TALLA, $this->talla);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(ExamfisPeer::DATABASE_NAME);

		$criteria->add(ExamfisPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setNumhistoria($this->numhistoria);

		$copyObj->setTa($this->ta);

		$copyObj->setPulso($this->pulso);

		$copyObj->setFc($this->fc);

		$copyObj->setFresp($this->fresp);

		$copyObj->setPeso($this->peso);

		$copyObj->setTalla($this->talla);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new ExamfisPeer();
		}
		return self::$peer;
	}

	
	public function setHistoria($v)
	{


		if ($v === null) {
			$this->setNumhistoria(NULL);
		} else {
			$this->setNumhistoria($v->getNumhistoria());
		}


		$this->aHistoria = $v;
	}


	
	public function getHistoria($con = null)
	{
		if ($this->aHistoria === null && ($this->numhistoria !== null)) {
						$this->aHistoria = HistoriaPeer::retrieveByPK($this->numhistoria, $con);

			
		}
		return $this->aHistoria;
	}

} 